#ifndef JAE_SCENEMANAGER_H
#define JAE_SCENEMANAGER_H

#include "node.h"
#include "objectMS3D.h"

/****************************************************//**
 * Project-Namespace
 ********************************************************/
namespace jae
{
 
/****************************************************//**
 * SzenenManager, der die darzustellende Szene verwaltet.
 ********************************************************/
class SceneManager 
{

public:
	SceneManager();
	~SceneManager();

	Node* getRootNode();
	TextureManager* getTextureManager();
    void renderObjects();
    void updateGLLights();
    Camera* createCamera(Node* aParentNode = NULL);
    Light* createLight(Node* aParentNode = NULL);
    Node* createChildNode(Node* aParentNode = NULL);
    Object* createObject(const char* aFilename, Node* aParentNode = NULL);
    Object* createTerrainObject(const char* aFilename, Node* aParentNode = NULL);
    bool loadSceneFromFile(const char* aFilename);
    QGLWidget* getSharedGLContext();
    void clearScene();
    bool isEmpty();
    void setClearColor(GLclampf aRed, GLclampf aGreen, GLclampf aBlue, GLclampf aAlpha);
    void setFogColor(GLfloat aRed, GLfloat aGreen, GLfloat aBlue, GLfloat aAlpha);
    void setFogMode(GLuint aMode);
    void setFogStartDepth(GLfloat aStart);
    void setFogEndDepth(GLfloat aEnd);
    void setFogDensity(GLfloat aDensity);
    GLfloat getFogDensity();
    GLfloat getFogStartDepth();
    GLfloat getFogEndDepth();
    GLuint getFogMode();
    void initRendering();
    
    
    
private:
    bool getNextParam(std::string* aLine, std::string* aNextParam);
    void checkLineSyntax(const char* aFilename, int lineNumber, 
            std::string& aCommand, int aParamCount, int aExpectedCount);
    void noObjectCreated(const char* aFilename, int lineNumber, std::string& aCommand);
    void noLightCreated(const char* aFilename, int lineNumber, std::string& aCommand);

    class Object_Info
    {
    public:
            std::string name;
            Object *pObject;
    };
    List<Object_Info> _objectInfoList;
    
    Node _rootNode;
    GLclampf _clearColor[4];
    TextureManager* _pTextureManager;
    QGLWidget* _pSharedGLContext;
    GLenum _maxLights;
    GLuint _numberOfLights;
    GLuint _fogMode;
    GLfloat _fogColors[4];
    GLfloat _fogStart;
    GLfloat _fogEnd;
    GLfloat _fogDensity;
    
};


} //namespace

#endif /*JAE_SCENEMANAGER_*/
